<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<style>
    /* html,body{
      width: 100%;
      padding: 100%;
      background-color: cyan;
    } */
    .box {
        width: 100%;
        border: 1px solid black;
        /*clear: both;*/
        /*方法一： 父元素添加 overflow:hidden*/
        /*overflow: hidden;*/
    }

    /*方法二: 给父元素一个空的伪类*/
    .box:after {
        content: "";
        height: 0;
        clear: both;
        overflow: hidden;
        display: block;
        visibility: hidden;
    }

    .item1 {
        width: 100px;
        height: 100px;
        float: left;
        border: 1px solid black;
    }

    .item2 {
        width: 100px;
        height: 100px;
        float: right;
        border: 1px solid black;
    }

    /*方法二:  在最后一个元素后, 添加一个无意义的div, 设置为这样的状态*/
    /*.lastItem {*/
    /*    overflow: hidden;*/
    /*    clear: both;*/
    /*    height: 0;*/
    /*}*/
</style>
<div class="box">
    <div class="item1"></div>
    <div class="item2"></div>
    <div class="lastItem"></div>
</div>
</body>
</html>
